home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_062
/
hackiconii_source
/
setcolors.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
10KB
|
310 lines
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
* |_o_o|\\ Copyright (c) 1987 The Software Distillery. All Rights Reserved *
* |. o.| || Written by Doug Walker *
* | . | || The Software Distillery *
* | o | || 235 Trillingham Lane *
* | . |// Cary, NC 27511 *
* ====== BBS:(919)-471-6436 *
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "mydebug.h"
#include "exec/types.h"
#include "exec/memory.h"
#include "intuition/intuition.h"
#include "graphics/gfxbase.h"
#include "stdio.h"
#include "hackicon.h"
extern struct Menu Titles[], ORCTitles[], ColorTitles[];
extern struct Border Borders[];
extern struct Screen *Screen;
extern struct Window *Window;
extern struct ViewPort *ViewPort;
extern struct IntuiText MiscText[];
extern struct PropInfo r_prop, g_prop, b_prop;
extern struct Gadget red_gad, blue_gad, green_gad;
extern USHORT colormap[];
static USHORT tmpmap[16];
extern int hires;
extern struct iconfont *fonts[];
extern int fontnum;
void PickColor(cnum, PalWindow, curcol)
int cnum, curcol;
struct Window *PalWindow;
{
/*
* SetAPen(calling_window->RPort,cursel);
* RectFill(calling_window->RPort,PLXLEFT+133, PLYTOP+3,
* PLXLEFT+PLWIDTH-5,PLYTOP+16);
*/
r_prop.HorizPot = (tmpmap[cnum] & 0xf00) << 4;
g_prop.HorizPot = (tmpmap[cnum] & 0x0f0) << 8;
b_prop.HorizPot = tmpmap[cnum] << 12;
Borders[2].FrontPen = 0;
DrawBorder(PalWindow->RPort, &Borders[2],
(curcol<16 ? 0 : PLXWIDTH+2),
(curcol%16)*PLYHEIGHT);
RefreshGadgets(&red_gad, PalWindow, NULL);
Borders[2].FrontPen = 1;
DrawBorder(PalWindow->RPort, &Borders[2],
(cnum<16 ? 0 : PLXWIDTH+2),
(cnum%16)*PLYHEIGHT);
}
SetColors()
{
struct NewWindow *NewWindow;
struct Window *PalWindow;
struct ViewPort *PalVP;
struct IntuiMessage *imsg;
struct Gadget *Gadget;
int flag, i;
USHORT Code, curcolor, partial;
ULONG Class;
BUG(1, ("SetColors: Enter\n"))
r_prop.Flags = g_prop.Flags = b_prop.Flags = FREEHORIZ | AUTOKNOB;
r_prop.HorizBody = g_prop.HorizBody = b_prop.HorizBody = 0x1000;
curcolor = 0;
movmem((char *)colormap, (char *)tmpmap, 16*sizeof(USHORT));
/* Disable Menus */
ClearMenuStrip(Window);
if(!(NewWindow = (struct NewWindow *)
AllocMem(sizeof(struct NewWindow), MEMF_CHIP | MEMF_CLEAR))
)
{
AutoRequest(Window, &MiscText[3], NULL, &MiscText[2], 0, 0, 410, 90);
return(1);
}
NewWindow->LeftEdge = SWIDTH/4;
NewWindow->TopEdge = SHEIGHT/4;
NewWindow->Width = CESWIDTH + PLXWIDTH+4;
NewWindow->Height = CESHEIGHT;
NewWindow->DetailPen = 1;
NewWindow->BlockPen = 2;
NewWindow->IDCMPFlags = (GADGETUP | GADGETDOWN | MOUSEMOVE | MENUPICK);
NewWindow->Flags = (SMART_REFRESH | ACTIVATE | WINDOWDRAG);
NewWindow->Title = (UBYTE *) "Palette Window";
NewWindow->Screen = Screen;
NewWindow->MinWidth =
NewWindow->MaxWidth = SWIDTH/2;
NewWindow->MinHeight =
NewWindow->MaxHeight = SHEIGHT/2;
NewWindow->Type = CUSTOMSCREEN;
NewWindow->FirstGadget = &red_gad;
PalWindow = (struct Window *)OpenWindow(NewWindow);
BUG(9, ("SetColors: Window open\n"))
DrawBorder(PalWindow->RPort, &Borders[1], 0, 0);
if(hires) DrawBorder(PalWindow->RPort, &Borders[1], PLXWIDTH+3, 0);
PickColor(0, PalWindow, 0);
ORCTitles[0].NextMenu = ColorTitles;
SetMenuStrip(PalWindow, ORCTitles);
FreeMem(NewWindow, sizeof(struct NewWindow));
BUG(9, ("SetColors: newwindow mem freed\n"))
PalVP= (struct ViewPort *) ViewPortAddress(PalWindow);
LoadRGB4(PalVP, tmpmap, 16);
for(flag=1; flag; )
{
if(!(imsg = (struct IntuiMessage *)GetMsg(PalWindow->UserPort)))
{
WaitPort(PalWindow->UserPort);
continue;
}
DOMSG:
BUG(4, ("SetColors: at DOMSG, Class=%d\n", imsg->Class))
Class = imsg->Class;
Code = imsg->Code;
Gadget = (struct Gadget *)imsg->IAddress;
ReplyMsg(imsg);
switch(Class)
{
case GADGETDOWN:
case MOUSEMOVE:
BUG(1, ("SetColors: Case GADGETDOWN\n"))
if(Gadget->GadgetID > 15)
{
BUG(1, ("SetColors: [RGB] gadget\n"))
if(Gadget->GadgetID == G_RED)
{
partial = ((g_prop.HorizPot >> 8) & 0xf0) +
(b_prop.HorizPot >>12);
while(1)
{
if(imsg=(struct IntuiMessage *)
GetMsg(PalWindow->UserPort))
{
tmpmap[curcolor]=((r_prop.HorizPot>>4) & 0xf00) + partial;
LoadRGB4(PalVP, tmpmap, 16);
if(imsg->Class != MOUSEMOVE) goto DOMSG;
ReplyMsg(imsg);
}
else
WaitPort(PalWindow->UserPort);
}
}
else if(Gadget->GadgetID == G_GREEN)
{
partial = ((r_prop.HorizPot >> 4) & 0xf00) +
(b_prop.HorizPot >>12);
while(1)
{
if(imsg=(struct IntuiMessage *)
GetMsg(PalWindow->UserPort))
{
tmpmap[curcolor]=((g_prop.HorizPot>>8) & 0xf0) + partial;
LoadRGB4(PalVP, tmpmap, 16);
if(imsg->Class != MOUSEMOVE) goto DOMSG;
ReplyMsg(imsg);
}
else
WaitPort(PalWindow->UserPort);
}
}
else
{
partial = ((r_prop.HorizPot >> 4) & 0xf00) +
((g_prop.HorizPot >> 8) & 0xf0);
while(1)
{
if(imsg=(struct IntuiMessage *)
GetMsg(PalWindow->UserPort))
{
tmpmap[curcolor] = (b_prop.HorizPot >> 12) + partial;
LoadRGB4(PalVP, tmpmap, 16);
if(imsg->Class != MOUSEMOVE) goto DOMSG;
ReplyMsg(imsg);
}
if(!imsg) WaitPort(PalWindow->UserPort);
}
}
}
BUG(1, ("SetColors: End case GADGETDOWN\n"))
break;
case GADGETUP:
BUG(1, ("SetColors: Case GADGETUP\n"))
switch(Gadget->GadgetID)
{
case G_RED:
case G_GREEN:
case G_BLUE:
BUG(1, ("SetColors: Case RED, GREEN or BLUE\n"))
break;
default:
/* Must be a color selection gadget */
PickColor(Gadget->GadgetID, PalWindow, curcolor);
curcolor = Gadget->GadgetID;
BUG(5, ("SetColors: Color gadget # %d\n", curcolor))
break;
}
break;
case MENUPICK:
if(Code == MENUNULL) break;
BUG(8, ("SetColors: itemnum = %d, subnum=%d\n", ITEMNUM(Code), SUBNUM(Code)))
if(!MENUNUM(Code))
{
switch(ITEMNUM(Code))
{
case ME_SAVE:
BUG(1, ("SetColors: Case OK\n"))
flag = 0;
movmem((char *)tmpmap, (char *)colormap, 16*sizeof(USHORT));
break;
case ME_QUIT:
BUG(1, ("SetColors: Case CANCEL\n"))
LoadRGB4(PalVP, colormap, 16);
flag = 0;
break;
case ME_RESET:
BUG(1, ("SetColors: Case RESET\n"))
movmem((char *)colormap, (char *)tmpmap, 16*sizeof(USHORT));
LoadRGB4(PalVP, tmpmap, 16);
PickColor(curcolor, PalWindow, curcolor);
break;
}
}
else
{
switch(ITEMNUM(Code))
{
case MC_ORGCOL:
movmem((char *)fonts[fontnum]->colormap,
(char *)tmpmap,16*sizeof(USHORT));
LoadRGB4(PalVP, tmpmap, 16);
break;
case MC_ALTCOL:
i = fontnum;
do
{
i = (i+1)%MAXFONTS;
if(fonts[i]) break;
}
while(i != fontnum);
if(i == fontnum)
DisplayBeep(NULL);
else
{
movmem((char *)fonts[i]->colormap,
(char *)tmpmap,16*sizeof(USHORT));
LoadRGB4(PalVP, tmpmap, 16);
PickColor(curcolor, PalWindow, curcolor);
}
break;
}
}
break;
default:
BUG(1, ("SetColors: Unknown Class = %d\n", Class))
break;
}
}
while(imsg = (struct IntuiMessage *)GetMsg(Window->UserPort))
ReplyMsg(imsg);
ClearMenuStrip(PalWindow);
CloseWindow(PalWindow);
SetMenuStrip(Window, Titles);
BUG(1, ("SetColors: Exit\n"))
return(0);
}